package org.fnzn.service.Impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.fnzn.dao.LrdRolefuncMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.fnzn.bean.LrdRolefunc;
import org.fnzn.core.Result;
import org.fnzn.service.LrdRoleFuncService;
import org.fnzn.util.ResultGenerator;

import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example.Criteria;

@Service
public class LrdRoleFuncServiceImpl  implements LrdRoleFuncService {
	
	@Autowired
    LrdRolefuncMapper lrdRolefuncMapper;
	@Override
	public Result findLrdRoleFunc(LrdRolefunc lrdRolefunc) {
		// TODO Auto-generated method stub
		Condition condition = new Condition(LrdRolefunc.class);
		Criteria criteria = condition.createCriteria();
		if(StringUtils.isNotBlank(lrdRolefunc.getCorpCd())){
			criteria.andEqualTo("corpCd",lrdRolefunc.getCorpCd());
		}
		if(StringUtils.isNotBlank(lrdRolefunc.getRoleCd())){
			criteria.andEqualTo("roleCd",lrdRolefunc.getRoleCd());
		}
		List<LrdRolefunc> list = lrdRolefuncMapper.selectByExample(condition);
		return ResultGenerator.genSuccessResult(list);
	}

	@Override
	public List<Integer> selectIdsByRoleCd(String roleCd){
		return lrdRolefuncMapper.selectIdsByRoleCd(roleCd);
	}
}
